package com.fare.taluo.application.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.GlobalsConst;
import com.fare.taluo.core.domain.analyse.alert.FreightPriceAnalyseAlertConfigEntity;
import com.fare.taluo.util.I18nUtil;
import com.fare.taluo.vo.core.FreightPriceAnalyseAlertConfigVo;
import com.fare.taluo.application.FreightPriceAnalyseAlertConfigApplication;
import com.foreveross.crawl.common.util.DateUtil;

@Transactional
@Scope("singleton")
@Service("freightPriceAnalyseAlertConfigApplication")
public class FreightPriceAnalyseAlertConfigApplicationImpl implements
		FreightPriceAnalyseAlertConfigApplication {

	@Override
	public void saveOrUpdate(FreightPriceAnalyseAlertConfigVo fcVo) throws Exception {
		FreightPriceAnalyseAlertConfigEntity entity = new FreightPriceAnalyseAlertConfigEntity();
		if(fcVo.getId() != null){
			entity = entity.getFreightPriceAnalyseAlertConfig(fcVo.getId());
		}else{
			entity.setCreator(fcVo.getCreator());
			entity.setCreatorName(fcVo.getCreatorName());
			entity.setCreateTime(fcVo.getCreateTime());
		}
		entity.setId(fcVo.getId());
		entity.setUpdator(fcVo.getUpdator());
		entity.setUpdatorName(fcVo.getUpdatorName());
		entity.setUpdateTime(fcVo.getUpdateTime());	
		entity.setAirCompany(fcVo.getAirCompany());
		entity.setFutureDays(fcVo.getFutureDays());
		entity.setTriggerCondition(fcVo.getTriggerCondition());
		entity.setFromCity(fcVo.getFromCity());
		entity.setFromCityName(fcVo.getFromCityName());
		entity.setToCity(fcVo.getToCity());
		entity.setToCityName(fcVo.getToCityName());
		entity.setStartTime(fcVo.getStartTime());
		entity.setEndTime(fcVo.getEndTime());
		entity.setSpreadThan(fcVo.getSpreadThan());
		entity.setAlertWay(fcVo.getAlertWay());
		entity.setAlertFrequency(fcVo.getAlertFrequency());
		entity.setBookingType(fcVo.getBookingType());
		entity.setAirCompany(fcVo.getAirCompany());
		entity.setCarrierKey(fcVo.getCarrierKey());
		entity.setFlightDate(fcVo.getFlightDate());
		entity.setFlightNo(fcVo.getFlightNo());
		entity.setAlertWay(fcVo.getAlertWay());
		/*entity.setContrastAircompany(fcVo.getContrastAircompany());
		entity.setContrastAircompanyKey(fcVo.getContrastAircompanyKey());*/
		entity.setContrastFlightNo(fcVo.getContrastFlightNo());
		entity.setContrastSource(fcVo.getContrastSource());
		entity.setContrastSourceKey(fcVo.getContrastSourceKey());
		entity.setCabinLevel(fcVo.getCabinLevel());
	    entity.setTriggerConditionSpread(fcVo.getTriggerConditionSpread());
	    entity.setAlertType(Integer.parseInt(fcVo.getAlertType()));
	    entity.setContrastCabinLevel(fcVo.getContrastCabinLevel());
		entity.save();
	}

	@Override
	public List<FreightPriceAnalyseAlertConfigVo> getAllAnalyseAlertByC(
			String alertType ,Date createTime,Date endCreateTime,Long userId) {

		List<FreightPriceAnalyseAlertConfigEntity> listpo = 
				new FreightPriceAnalyseAlertConfigEntity().
					getAllAnalyseAlertByC( alertType , createTime,endCreateTime ,userId);
		List<FreightPriceAnalyseAlertConfigVo> listvo = new ArrayList<FreightPriceAnalyseAlertConfigVo>();
		
		if(listpo!=null){
			for(FreightPriceAnalyseAlertConfigEntity f : listpo){
				FreightPriceAnalyseAlertConfigVo vo = this.convertEntity2Vo(f);
				
				
				listvo.add(vo);
			}
		}
		return listvo;
	}

	@Override
	public List<FreightPriceAnalyseAlertConfigVo> getAllAnalyseAlert(Long userID) {
		// TODO Auto-generated method stub
		try {
			List<FreightPriceAnalyseAlertConfigEntity> listpo = new ArrayList<FreightPriceAnalyseAlertConfigEntity>();
			FreightPriceAnalyseAlertConfigEntity fpac = new FreightPriceAnalyseAlertConfigEntity();
			listpo=fpac.getAllAnalyseAlert(userID);
			List<FreightPriceAnalyseAlertConfigVo> listvo = new ArrayList<FreightPriceAnalyseAlertConfigVo>();
			if(listpo!=null){
				for(FreightPriceAnalyseAlertConfigEntity f : listpo){
					FreightPriceAnalyseAlertConfigVo vo = this.convertEntity2Vo(f);
					listvo.add(vo);
					
					}
					
					
				}
			
			return listvo;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@Override
	public List<FreightPriceAnalyseAlertConfigVo> getAllAnalyseAlert(
			Long userID, Locale locale) {
				try {
					List<FreightPriceAnalyseAlertConfigEntity> listpo = new ArrayList<FreightPriceAnalyseAlertConfigEntity>();
					FreightPriceAnalyseAlertConfigEntity fpac = new FreightPriceAnalyseAlertConfigEntity();
					listpo=fpac.getAllAnalyseAlert(userID);
					List<FreightPriceAnalyseAlertConfigVo> listvo = new ArrayList<FreightPriceAnalyseAlertConfigVo>();
					if(listpo!=null){
						for(FreightPriceAnalyseAlertConfigEntity f : listpo){
							FreightPriceAnalyseAlertConfigVo vo = this.convertEntity2Vo(f,locale);
							listvo.add(vo);
							
							}
							
							
						}
					
					return listvo;
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
	}

	@Override
	public FreightPriceAnalyseAlertConfigVo getFreightPriceAnalyseAlertConfig(
			Long id) {
		FreightPriceAnalyseAlertConfigEntity po = new FreightPriceAnalyseAlertConfigEntity().getFreightPriceAnalyseAlertConfig(id);
		FreightPriceAnalyseAlertConfigVo vo = null;
		if(po!=null){
			vo = this.convertEntity2Vo(po);
				
		}
		return vo;
	}

	@Override
	public void delete(Long id) {
		FreightPriceAnalyseAlertConfigEntity entity = new FreightPriceAnalyseAlertConfigEntity().getFreightPriceAnalyseAlertConfig(id);
		entity.delete();
	}
	
	private String intNameToString(int i){
		if(i == 1)
			return "邮件";
		return "邮件";
	}

	@Override
	public FreightPriceAnalyseAlertConfigVo getConfigByLine(String hbaseKey,
			String fromCityCode, String toCityCode,  Long userId) {
		FreightPriceAnalyseAlertConfigEntity entity = new FreightPriceAnalyseAlertConfigEntity().getConfig(hbaseKey, fromCityCode, toCityCode, userId);
		return this.convertEntity2Vo(entity);
	}
	
	
	public FreightPriceAnalyseAlertConfigVo getCabinChangeConfig(String flightNo,String flightDate,Long userId){
		FreightPriceAnalyseAlertConfigEntity entity = new FreightPriceAnalyseAlertConfigEntity().getCabinChangeConfig(flightNo, flightDate, userId);
		return this.convertEntity2Vo(entity);
	}
   
	public FreightPriceAnalyseAlertConfigVo getSpreadConfig(String flightNo,String flightDate,String contrastSourceKey, Long userId){
		FreightPriceAnalyseAlertConfigEntity entity = new FreightPriceAnalyseAlertConfigEntity().getSpreadConfig( flightNo, flightDate, contrastSourceKey,userId);
		return this.convertEntity2Vo(entity);		
	}
	
	public FreightPriceAnalyseAlertConfigVo getContrastConfig(String flightNo,String contrastFlightNo,String flightDate,Long userId){
		FreightPriceAnalyseAlertConfigEntity entity = new FreightPriceAnalyseAlertConfigEntity().getContrastConfig( flightNo,contrastFlightNo, flightDate ,userId);
		return this.convertEntity2Vo(entity);
	}
	private FreightPriceAnalyseAlertConfigVo convertEntity2Vo(FreightPriceAnalyseAlertConfigEntity entity){
		FreightPriceAnalyseAlertConfigVo vo = null;
		if(entity != null){
			vo = new FreightPriceAnalyseAlertConfigVo();
			vo.setCreator(entity.getCreator());
			vo.setCreatorName(entity.getCreatorName());
			vo.setCreateTime(entity.getCreateTime());
			vo.setUpdator(entity.getUpdator());
			vo.setUpdatorName(entity.getUpdatorName());
			vo.setUpdateTime(entity.getUpdateTime());
			vo.setFromCity(entity.getFromCity());
			vo.setFromCityName(entity.getFromCityName());
			vo.setToCity(entity.getToCity());
			vo.setToCityName(entity.getToCityName());
			vo.setAirCompany(entity.getAirCompany());
			vo.setFutureDays(entity.getFutureDays());
			vo.setTriggerCondition(entity.getTriggerCondition());

			vo.setStartTime(entity.getStartTime());
			vo.setEndTime(entity.getEndTime());
			
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			vo.setStartTimeString(entity.getStartTime()==null?"":sdf.format(entity.getStartTime()));
			vo.setEndTimeString(entity.getEndTime()==null?"":sdf.format(entity.getEndTime()));
			
			vo.setSpreadThan(entity.getSpreadThan());
			vo.setAlertWay(entity.getAlertWay());
			vo.setAlertWayName(intNameToString(entity.getAlertWay()));
			vo.setAlertFrequency(entity.getAlertFrequency());
			vo.setBookingType(entity.getBookingType());
			vo.setId(entity.getId());
			
			vo.setAirCompany(entity.getAirCompany());
			vo.setCabinLevel(entity.getCabinLevel());
			vo.setCarrierKey(entity.getCarrierKey());
		/*	vo.setContrastAircompany(entity.getContrastAircompany());
			vo.setContrastAircompanyKey(entity.getContrastAircompanyKey());*/
			vo.setContrastFlightNo(entity.getContrastFlightNo());
			vo.setContrastSource(entity.getContrastSource());
			vo.setContrastSourceKey(entity.getContrastSourceKey());
			vo.setFlightDate(entity.getFlightDate());
			vo.setContrastCabinLevel(entity.getContrastCabinLevel());
			vo.setTriggerConditionSpread(entity.getTriggerConditionSpread()==null?0:entity.getTriggerConditionSpread());
			if(entity.getAlertType()!=null){
				String alertDescription = null;
				/*String cabinName = null;
				if(entity.getCabinLevel()!=null){
					if( entity.getCabinLevel().contains("经济")){
						cabinName = "经济舱";
					}else if(entity.getCabinLevel().contains("商务")){
						cabinName = "商务舱";
					}else if(entity.getCabinLevel().contains("头等")){
						cabinName = "头等舱";
					}
				}*/
				
				if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_LOWEST_PRICE)){
					vo.setAlertType("最低价预警");
					String upOrDown = null;
					if("0".equals(""+entity.getBookingType())){
						upOrDown = "以下本航是最低价";
					}else if("1".equals(""+entity.getBookingType())){
						upOrDown = "以上本航是最低价";
					}
					
				    alertDescription = DateUtil.formatDay(entity.getStartTime(),"yyyy-MM-dd")+"至"+DateUtil.formatDay(entity.getEndTime(),"yyyy-MM-dd")+
					" , <span style=\"color: #ff0000\"> "+entity.getFromCityName()+"</span>- <span style=\"color: #ff0000\">"+entity.getToCityName()+"</span>在未来<span style=\"color: #ff0000\">"+entity.getFutureDays()+"</span>天的价格有<span style=\"color: #ff0000\">"+entity.getTriggerCondition()+"</span>天"+upOrDown;
				}else if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_CABIN_CHANGE)){
					vo.setAlertType("舱位变动预警");
					alertDescription =DateUtil.formatDay(entity.getFlightDate(),"yyyy-MM-dd")+"起飞的<span style=\"color: #ff0000\">"+entity.getAirCompany()+entity.getFlightNo()+"</span> ,出现舱位变化";
				}else if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_STREAD)){
					vo.setAlertType("价差预警");
					
					alertDescription = DateUtil.formatDay(entity.getFlightDate(),"yyyy-MM-dd")+"起飞的<span style=\"color: #ff0000\">"+entity.getAirCompany()+entity.getFlightNo()+"</span> ,连续<span style=\"color: #ff0000\">"+entity.getTriggerCondition()
							+"</span>天官网<span style=\"color: #ff0000\">"+entity.getCabinLevel()+"</span>的<span style=\"color: #ff0000\">最低价</span>和<span style=\"color: #ff0000\">"+entity.getContrastSource()+"</span>价差大于<span style=\"color: #ff0000\">"+entity.getTriggerConditionSpread()+"%</span>";
				}else if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_COMPETE_CONTRAST)){
					vo.setAlertType("竞争对比预警");
					String contrastCabinName = null;
					if(entity.getContrastCabinLevel()!=null){
						contrastCabinName = entity.getContrastCabinLevel();
						/*if( entity.getContrastCabinLevel().equals("0")){
							contrastCabinName = "经济舱";
						}else if(entity.getCabinLevel().equals("1")){
							contrastCabinName = "商务舱";
						}else if(entity.getCabinLevel().equals("2")){
							contrastCabinName = "头等舱";
						}*/
					}
					String flag = null;
					if(entity.getTriggerCondition() == 1){
						flag = "高于";
					}else{
						flag = "低于";
					}
					
					
					alertDescription = DateUtil.formatDay(entity.getFlightDate(),"yyyy-MM-dd")+"起飞的<span style=\"color: #ff0000\">"+entity.getAirCompany()+entity.getFlightNo()+"</span> ,连续<span style=\"color: #ff0000\">"+entity.getFutureDays()
							+"</span>天官网<span style=\"color: #ff0000\">"+entity.getCabinLevel()+"</span>的<span style=\"color: #ff0000\">最低价</span>"+flag+"同天起飞的<span style=\"color: #ff0000\">"+entity.getContrastSource()+entity.getContrastFlightNo()+"</span>的官网<span style=\"color: #ff0000\">"+contrastCabinName+"</span>最低价";
				}
				vo.setAlertDescription(alertDescription);
			   
			}
		
		}
		return vo;
	}
	
	private FreightPriceAnalyseAlertConfigVo convertEntity2Vo(
			FreightPriceAnalyseAlertConfigEntity entity, Locale locale) {
		FreightPriceAnalyseAlertConfigVo vo = null;
		if(entity != null){
			vo = new FreightPriceAnalyseAlertConfigVo();
			vo.setCreator(entity.getCreator());
			vo.setCreatorName(entity.getCreatorName());
			vo.setCreateTime(entity.getCreateTime());
			vo.setUpdator(entity.getUpdator());
			vo.setUpdatorName(entity.getUpdatorName());
			vo.setUpdateTime(entity.getUpdateTime());
			vo.setFromCity(entity.getFromCity());
			vo.setFromCityName(entity.getFromCityName());
			vo.setToCity(entity.getToCity());
			vo.setToCityName(entity.getToCityName());
			vo.setAirCompany(entity.getAirCompany());
			vo.setFutureDays(entity.getFutureDays());
			vo.setTriggerCondition(entity.getTriggerCondition());

			vo.setStartTime(entity.getStartTime());
			vo.setEndTime(entity.getEndTime());
			
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			vo.setStartTimeString(entity.getStartTime()==null?"":sdf.format(entity.getStartTime()));
			vo.setEndTimeString(entity.getEndTime()==null?"":sdf.format(entity.getEndTime()));
			
			vo.setSpreadThan(entity.getSpreadThan());
			vo.setAlertWay(entity.getAlertWay());
			vo.setAlertWayName(intNameToString(entity.getAlertWay()));
			vo.setAlertFrequency(entity.getAlertFrequency());
			vo.setBookingType(entity.getBookingType());
			vo.setId(entity.getId());
			
			vo.setAirCompany(entity.getAirCompany());
			vo.setCabinLevel(entity.getCabinLevel());
			vo.setCarrierKey(entity.getCarrierKey());
		/*	vo.setContrastAircompany(entity.getContrastAircompany());
			vo.setContrastAircompanyKey(entity.getContrastAircompanyKey());*/
			vo.setContrastFlightNo(entity.getContrastFlightNo());
			vo.setContrastSource(entity.getContrastSource());
			vo.setContrastSourceKey(entity.getContrastSourceKey());
			vo.setFlightDate(entity.getFlightDate());
			vo.setContrastCabinLevel(entity.getContrastCabinLevel());
			vo.setTriggerConditionSpread(entity.getTriggerConditionSpread()==null?0:entity.getTriggerConditionSpread());
		
			if(entity.getAlertType()!=null){
				String alertDescription = null;
				/*String cabinName = null;
				if(entity.getCabinLevel()!=null){
					if( entity.getCabinLevel().contains("经济")){
						cabinName = "经济舱";
					}else if(entity.getCabinLevel().contains("商务")){
						cabinName = "商务舱";
					}else if(entity.getCabinLevel().contains("头等")){
						cabinName = "头等舱";
					}
				}*/
				
				if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_LOWEST_PRICE)){
					vo.setAlertType(null==I18nUtil.getProperties(locale).get("forms.lowestAlert")?"最低价预警":I18nUtil.getProperties(locale).get("forms.lowestAlert"));
					
					String upOrDown = null;
					if("0".equals(""+entity.getBookingType())){
						String des=I18nUtil.getProperties(locale).get("forms.following") +" "+ I18nUtil.getProperties(locale).get("forms.isTheLowest");
						upOrDown = "以下本航是最低价";
						if(null!=des){
							upOrDown=des;
						}
						
					}else if("1".equals(""+entity.getBookingType())){
						upOrDown = "以上本航是最低价";
						String des=I18nUtil.getProperties(locale).get("forms.above") +" "+ I18nUtil.getProperties(locale).get("forms.isTheLowest");
						if(null!=des){
							upOrDown=des;
						}
					}
					String fromCityName =entity.getFromCityName();
					if(null!=fromCityName && fromCityName.indexOf("(")>0){
						fromCityName=fromCityName.substring(0, fromCityName.indexOf("("));
					}
					String toCityName=entity.getToCityName();
					if(null!=toCityName && toCityName.indexOf("(")>0){
						toCityName=toCityName.substring(0, toCityName.indexOf("("));
					}
					
				    alertDescription = DateUtil.formatDay(entity.getStartTime(),"yyyy-MM-dd")+"~"+DateUtil.formatDay(entity.getEndTime(),"yyyy-MM-dd")+
					" , <span style=\"color: #ff0000\"> "+
				    		(null==I18nUtil.getProperties(locale).get(fromCityName)?entity.getFromCityName():I18nUtil.getProperties(locale).get(fromCityName))+
				    		"</span>- <span style=\"color: #ff0000\">"+
				    		(null==I18nUtil.getProperties(locale).get(toCityName)?entity.getToCityName():I18nUtil.getProperties(locale).get(toCityName))+
				    		"</span>" +
							(null==I18nUtil.getProperties(locale).get("forms.Inthefuture")?"在未来":I18nUtil.getProperties(locale).get("forms.Inthefuture")) +
							"<span style=\"color: #ff0000\">"+entity.getFutureDays()+
					"</span>" +
					(null==I18nUtil.getProperties(locale).get("forms.daysOftheprice")?"天的价格有":I18nUtil.getProperties(locale).get("forms.daysOftheprice"))+
					"<span style=\"color: #ff0000\">"+entity.getTriggerCondition()+"</span>" +
							(null==I18nUtil.getProperties(locale).get("forms.days")?"天":I18nUtil.getProperties(locale).get("forms.days"))+
					upOrDown;
				}else if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_CABIN_CHANGE)){
					vo.setAlertType(null==I18nUtil.getProperties(locale).get("forms.cabinAlert")?"舱位变动预警":I18nUtil.getProperties(locale).get("forms.cabinAlert"));
					alertDescription =DateUtil.formatDay(entity.getFlightDate(),"yyyy-MM-dd")+
							(null==I18nUtil.getProperties(locale).get("forms.takeOff")?"起飞的":I18nUtil.getProperties(locale).get("forms.takeOff")) +
							"<span style=\"color: #ff0000\">"+
							(null==I18nUtil.getProperties(locale).get(entity.getAirCompany())?entity.getAirCompany():I18nUtil.getProperties(locale).get(entity.getAirCompany()))+
							entity.getFlightNo()+"</span> ," +
									(null==I18nUtil.getProperties(locale).get("forms.changesSppearAccommodation")?"出现舱位变化":I18nUtil.getProperties(locale).get("forms.changesSppearAccommodation"));
				}else if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_STREAD)){
					vo.setAlertType(null==I18nUtil.getProperties(locale).get("forms.spreadAlert")?"价差预警":I18nUtil.getProperties(locale).get("forms.spreadAlert"));
					
					alertDescription = DateUtil.formatDay(entity.getFlightDate(),"yyyy-MM-dd")+
							(null==I18nUtil.getProperties(locale).get("forms.takeOff")?"起飞的":I18nUtil.getProperties(locale).get("forms.takeOff")) +
							"<span style=\"color: #ff0000\">"+
							(null==I18nUtil.getProperties(locale).get(entity.getAirCompany())?entity.getAirCompany():I18nUtil.getProperties(locale).get(entity.getAirCompany()))+
							entity.getFlightNo()+"</span> ," +
									(null==I18nUtil.getProperties(locale).get("forms.continuous")?"连续":I18nUtil.getProperties(locale).get("forms.continuous") )+
									"<span style=\"color: #ff0000\">"+entity.getTriggerCondition()
							+"</span>" +
							(null==I18nUtil.getProperties(locale).get("forms.days")?"天":I18nUtil.getProperties(locale).get("forms.days")) +
							(null==I18nUtil.getProperties(locale).get("forms.B2C")?"官网":I18nUtil.getProperties(locale).get("forms.B2C")) +
							"<span style=\"color: #ff0000\">"+entity.getCabinLevel()+"</span>" +
									" " +(null==I18nUtil.getProperties(locale).get("forms.of")?"的":I18nUtil.getProperties(locale).get("forms.of"))+
									"<span style=\"color: #ff0000\">" +
									(null==I18nUtil.getProperties(locale).get("forms.lowestPrice")?"最低价":I18nUtil.getProperties(locale).get("forms.lowestPrice")) +
									"</span>" +
									(null==I18nUtil.getProperties(locale).get("forms.and")?"和":I18nUtil.getProperties(locale).get("forms.and")) +
									"<span style=\"color: #ff0000\">"+
									(null==I18nUtil.getProperties(locale).get(entity.getContrastSource())?entity.getContrastSource():I18nUtil.getProperties(locale).get(entity.getContrastSource()))
									+"</span>" +
									(null==I18nUtil.getProperties(locale).get("forms.spreadisgreaterthan")?"价差大于" :I18nUtil.getProperties(locale).get("forms.spreadisgreaterthan"))+
									"<span style=\"color: #ff0000\">"+entity.getTriggerConditionSpread()+"%</span>";
				}else if(entity.getAlertType().equals(GlobalsConst.ALERT_TYPE_COMPETE_CONTRAST)){
					vo.setAlertType(null==I18nUtil.getProperties(locale).get("forms.competitionAlert")?"竞争对比预警":I18nUtil.getProperties(locale).get("forms.competitionAlert"));
					String contrastCabinName = null;
					if(entity.getContrastCabinLevel()!=null){
						contrastCabinName = entity.getContrastCabinLevel();
						/*if( entity.getContrastCabinLevel().equals("0")){
							contrastCabinName = "经济舱";
						}else if(entity.getCabinLevel().equals("1")){
							contrastCabinName = "商务舱";
						}else if(entity.getCabinLevel().equals("2")){
							contrastCabinName = "头等舱";
						}*/
					}
					String flag = null;
					if(entity.getTriggerCondition() == 1){
						flag = (null==I18nUtil.getProperties(locale).get("forms.above")?"高于":I18nUtil.getProperties(locale).get("forms.above"));
					}else{
						flag = (null==I18nUtil.getProperties(locale).get("forms.below")?"低于":I18nUtil.getProperties(locale).get("forms.below"));
					}
					
					
					alertDescription = DateUtil.formatDay(entity.getFlightDate(),"yyyy-MM-dd")+
							(null==I18nUtil.getProperties(locale).get("forms.takeOff")?"起飞的":I18nUtil.getProperties(locale).get("forms.takeOff")) +
							"<span style=\"color: #ff0000\">"+
							(null==I18nUtil.getProperties(locale).get(entity.getAirCompany())?entity.getAirCompany():I18nUtil.getProperties(locale).get(entity.getAirCompany()))
							+entity.getFlightNo()+"</span> ," +
							(null==I18nUtil.getProperties(locale).get("forms.continuous")?"连续":I18nUtil.getProperties(locale).get("forms.continuous") )+
									"<span style=\"color: #ff0000\">"+entity.getFutureDays()
							+"</span>" +
							(null==I18nUtil.getProperties(locale).get("forms.days")?"天":I18nUtil.getProperties(locale).get("forms.days"))+
							(null==I18nUtil.getProperties(locale).get("forms.B2C")?"官网":I18nUtil.getProperties(locale).get("forms.B2C")) +
							"<span style=\"color: #ff0000\">"+entity.getCabinLevel()+"</span>" +
									(null==I18nUtil.getProperties(locale).get("forms.of")?"的":I18nUtil.getProperties(locale).get("forms.of")) +
									"<span style=\"color: #ff0000\">" +
							(null==I18nUtil.getProperties(locale).get("forms.lowestPrice")?"最低价":I18nUtil.getProperties(locale).get("forms.lowestPrice")) +
									"</span>"+flag+
									(null==I18nUtil.getProperties(locale).get("forms.sameDaytakeOff")?"同天起飞的":I18nUtil.getProperties(locale).get("forms.sameDaytakeOff"))+
									"<span style=\"color: #ff0000\">"+
									(null==I18nUtil.getProperties(locale).get(entity.getContrastSource())?entity.getContrastSource():I18nUtil.getProperties(locale).get(entity.getContrastSource()))
									+entity.getContrastFlightNo()+"</span>" +
									(null==I18nUtil.getProperties(locale).get("forms.of")?"的":I18nUtil.getProperties(locale).get("forms.of")) +
									(null==I18nUtil.getProperties(locale).get("forms.B2C")?"官网":I18nUtil.getProperties(locale).get("forms.B2C")) +
									"<span style=\"color: #ff0000\">"+contrastCabinName+"</span>" +
									(null==I18nUtil.getProperties(locale).get("forms.lowestPrice")?"最低价":I18nUtil.getProperties(locale).get("forms.lowestPrice"));
				}
				vo.setAlertDescription(alertDescription);
			   
			}
		
		}
		return vo;
	}

	

	
}
